﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblGroupDAO
    {
        private DBService _db = null;
        public TblGroupDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }

        public DataTable InsUp(TblGroup group, int mode)
        {

            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("sp_TblGroup_InsUp",
                    new string[] { "@IDGroup", "@GroupName", "@IdLang", "@mode"},
                    new object[] { group.IDGroup, group.GroupName, group.IdLang, mode}, CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetAll()
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("Select * from TblGroup", false, CommandType.Text);
              
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetGroup_ByID(int idGroup)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("Select * from TblGroup where IDGroup = @idGroup", 
                    new string[]{"@idGroup"},
                    new object[]{idGroup}, CommandType.Text);

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        // Lấy phân loại theo nhóm
        
    }
}
